{include file="../application/admin/view/common/header.html" /}

<!--main content start-->
<section class="main-content">


    <!--start page content-->

    <div class="row">

        <div class="col-md-12">

            <div class="panel panel-default collapsed">
                <ul class="list-inline tabs-nav" role="tablist">
                    <li role="presentation" class="active">
                        <a href="#copyright" aria-controls="copyright" role="tab" data-toggle="tab"
                           aria-expanded="true">全部订单</a>
                    </li>
                    <li role="presentation" class="">
                        <a href="#trademark" aria-controls="trademark" role="tab" data-toggle="tab"
                           aria-expanded="false">付款</a>
                    </li>
                    <li role="presentation" class="">
                        <a href="#proprietary-technology" aria-controls="proprietary-technology" role="tab"
                           data-toggle="tab" aria-expanded="false">退款</a>
                    </li>
                    <li role="presentation" class="">
                        <a href="#patent" aria-controls="patent" role="tab" data-toggle="tab"
                           aria-expanded="false">打款</a>
                    </li>
                </ul>
                <input type="hidden" value="" id="select2">
                <div class="panel-heading">
                    <label style="color: #666666;font-size: 16px;font-weight: normal;line-height: 34px;margin: 3px 0;margin-right: 25px;">宝贝类型:
                        <select id="select1" style="height: 34px;border:1px solid #e0e0e0;width: 150px; ">
                            <option value="0">全部</option>
                            <option value="1">交易类宝贝</option>
                            <option value="2">服务类宝贝</option>
                        </select>
                    </label>

                    <div class="float-m" style="display: inline-block;">
                        <label>日期范围:</label>
                        <input type="text" id="logmin" class="input-text Wdate"
                               style="width:100px;display: inline-block;">
                        -
                        <input type="text" id="logmax" class="input-text Wdate"
                               style="width:100px;display: inline-block;">
                    </div>
                    <div class="search-form">
                        <input type="text" class="form-control" placeholder="输入商品名称/订单编号"/>
                        <button type="button" id="submit" class="btn-search"><i class="fa fa-search"></i></button>
                    </div>
                </div>
                <div class="panel-body">

                    <table class="table table-hover table-striped table-bordered" data-page-size="12"
                           data-filter=#filter>
                        <thead>
                        <tr>
                            <th>选择</th>
                            <th>ID</th>
                            <th>订单编号</th>
                            <td>商品图片</td>
                            <th>商品名称</th>
                            <th>买家</th>
                            <th>卖家店铺</th>
                            <th>交易类型</th>
                            <th>交易状态</th>
                            <th>进账金额（元）</th>
                            <th>支出金额（元）</th>
                            <th>汇款时间</th>
                        </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>
                    <div class="pager" id="page" style="text-align: right;"></div>
                </div>
            </div>
        </div>
    </div><!--end row-->

    <!--end page content-->
</section>
<!--end main content-->


<!--Common plugins-->
<script src="_JS_/jquery.min.js"></script>
<script src="_JS_/jquery.base64.js"></script>
<script src="_JS_/jquery.cookie.js"></script>
<script src="_JS_/bootstrap.min.js"></script>
<script src="_JS_/jasny-bootstrap.min.js"></script>
<script src="_JS_/jquery.slimscroll.min.js"></script>
<script src="_JS_/jquery.nanoscroller.min.js"></script>
<script src="_JS_/metismenu.min.js"></script>
<script src="_JS_/float-custom.js"></script>
<script type="text/javascript" src="_JS_/layer/layer.js"></script>
<script type="text/javascript" src="_JS_/laypage/laypage.js"></script>
<script type="text/javascript" src="_JS_/laydata/laydate.js"></script>
<script type="text/javascript" src="_JS_/getMyDate.js"></script>
<!-- Page-Level Scripts -->
<script>
    $(function () {
        $("#page-title").html('订单明细管理');
        postfile(1);
    });


    $("li a").click(function () {
        if ($(this).text() == '付款') {
            $("#select2").val(1);
        } else if ($(this).text() == '退款') {
            $("#select2").val(2);
        } else if ($(this).text() == '打款') {
            $("#select2").val(3);
        } else {
            $("#select2").val(0);
        }
        postfile(1);
    });

    function postfile(page) {
        var services = $("#select1").val();
        var username = $('.search-form input').val();
        var logmin = $("#logmin").val();
        var logmax = $("#logmax").val();
        var static = $("#select2").val();
        $.ajax({
            type: 'GET',
            url: "{:url('api/orders/details_orders')}",
            dataType: 'jsonp',
            jsonp: 'callback',
            data: {
                'page': page,
                'services': services,
                'username': username,
                'logmin': logmin,
                'logmax': logmax,
                'static': static
            },
            beforeSend: function () {
                var index = layer.load(1, {
                    shade: [0.1, '#333333'] //0.1透明度的白色背景
                });
            },
            success: function (msg) {
                layer.closeAll();
                $("#details_management").addClass("active").children("ul").addClass("in");
                $("#details_orders").addClass("choose");
                if (msg.code == 200) {
                    var pages = Math.ceil(msg.data.count / 10);
                    $(".table tbody").html('');
                    if (msg.data.data.length > 0) {
                        for (var i = 0; i < msg.data.data.length; i++) {
                            var time = msg.data.data[i].time;
                            ltime = getMyDate(time * 1000);
                            if (msg.data.data[i].services == 1) {
                                var services = "交易类宝贝"
                            } else if (msg.data.data[i].services == 2) {
                                var services = "服务类宝贝"
                            }
                            var html = '<tr id="' + msg.data.data[i].id + '"><td><input type="checkbox" name=""></td><td>' + msg.data.data[i].id + '</td>' +
                                '<td>' + msg.data.data[i].order + '</td><td><img src="' + msg.data.data[i].image + '"></td>' +
                                '<td>' + msg.data.data[i].name + '</td><td>' + msg.data.data[i].username + '</td><td>' + msg.data.data[i].seller + '</td>';
                            if (msg.data.data[i].services == 1) {
                                html += '<td>交易类宝贝</td>';
                            } else if (msg.data.data[i].services == 2) {
                                html += '<td>服务类宝贝</td>';
                            }

                            if (msg.data.data[i].static == 1) {
                                html += '<td class="td-status enable">宝贝已拍下等待买家付款</td><td>' + msg.data.data[i].money + '</td><td>0</td>';
                            } else if (msg.data.data[i].static == 2) {
                                html += '<td class="td-status disable">协议不成功买家发起退款</td><td>' + msg.data.data[i].money + '</td><td>0</td>';
                            } else if (msg.data.data[i].static == 3) {
                                html += '<td class="td-status enable">平台确认合同，将双方合同互换后邮寄</td><td>' + msg.data.data[i].money + '</td><td>0</td>';
                            } else if (msg.data.data[i].static == 4) {
                                html += '<td class="td-status enable">双方确认收到对方合同,买家确认收货</td><td>' + msg.data.data[i].money + '</td><td>0</td>';
                            } else if (msg.data.data[i].static == 5) {
                                html += '<td class="td-status pass">交易完成</td><td>0</td><td>' + msg.data.data[i].money + '</td>';
                            } else if (msg.data.data[i].static == 6) {
                                html += '<td class="td-status disable">交易失败</td><td>0</td><td>' + msg.data.data[i].money + '</td>';
                            }

                            html += '<td>' + ltime + '</td></tr>';
                            $('.table tbody').append(html);
                        }
                    }
                    //分页
                    $(".table").attr("pages", page);
                    laypage({
                        cont: 'page',
                        pages: pages,
                        curr: page,
                        jump: function (obj, first) {
                            if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                                postfile(obj.curr);
                            }
                        }
                    })
                } else {
                    layer.msg('获取信息不成功!', {icon: 5, time: 2000});
                }
            }
        })
    }

    // 搜索
    $('#submit').click(function () {
        postfile(1);
    })

    //回车键绑定搜索
    $(".search-form").keydown(function (event) {
        if (event.keyCode == 13) {
            postfile(1);
        }
    });

    // 交易方式
    $("#select1").change(function () {
        postfile(1);
    });

    //日期范围限制
    var start = {
        elem: '#logmin',
        format: 'YYYY-MM-DD',
        min: '1970-01-01', //设定最小日期为当前日期
        max: laydate.now(), //最大日期
        istime: false,
        istoday: false,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    };

    var end = {
        elem: '#logmax',
        format: 'YYYY-MM-DD',
        min: '1970-01-01',
        max: laydate.now(),
        istime: false,
        istoday: false,
        choose: function (datas) {
            start.max = datas; //结束日选好后，充值开始日的最大日期
        }
    };
    laydate(start);
    laydate(end);

</script>
</body>
</html>